1 00:00:00,390 --> 00:00:00,660 All right. 2 00:00:00,660 --> 00:00:04,650 In this lesson, I'm going to make a wild loop where you can break the loop condition. 3 00:00:04,650 --> 00:00:06,330 So I have a spinning coin. 4 00:00:06,330 --> 00:00:09,960 If I run up and I touch it in any way, it's going to freeze. 5 00:00:09,960 --> 00:00:11,730 I'm breaking the loop condition. 6 00:00:11,730 --> 00:00:13,770 So let's go ahead and get started with that. 7 00:00:14,630 --> 00:00:14,930 All right. 8 00:00:14,930 --> 00:00:20,910 I'm going to use the power up coin from my last video and I'm going to put the link in the description. 9 00:00:20,930 --> 00:00:24,290 This is important to learn to using other people's assets. 10 00:00:24,290 --> 00:00:26,750 So I made this sharable in the marketplace. 11 00:00:26,750 --> 00:00:29,600 You click on this link, you're going to get to this page. 12 00:00:29,600 --> 00:00:36,230 There'll be a green get button when you press it and you open up Roblox studio. 13 00:00:36,470 --> 00:00:37,730 I have a fresh world. 14 00:00:37,820 --> 00:00:42,980 Go to your toolbox and under inventory you'll see the coin. 15 00:00:42,980 --> 00:00:43,430 Right? 16 00:00:43,430 --> 00:00:47,300 So this is Marketplace, this is inventory, this is your stuff. 17 00:00:47,300 --> 00:00:50,630 Once you said get, you're going to have access to that coin. 18 00:00:50,630 --> 00:00:53,360 This is the coin that I have. 19 00:00:54,120 --> 00:00:55,260 With that URL. 20 00:00:55,260 --> 00:00:56,750 So it says there are two scripts. 21 00:00:56,760 --> 00:00:57,210 Yeah. 22 00:00:57,270 --> 00:00:58,260 That's good. 23 00:00:58,920 --> 00:01:00,100 Let's take a look at this. 24 00:01:00,120 --> 00:01:01,500 It's a coin model. 25 00:01:02,010 --> 00:01:04,020 We saved it off in the last video. 26 00:01:04,110 --> 00:01:05,490 Let's move it up. 27 00:01:05,730 --> 00:01:12,570 And the coin spins with the rotate, and the collect allows you to grab the coin and get powers. 28 00:01:12,600 --> 00:01:15,480 Let's take a look at rotate first. 29 00:01:15,490 --> 00:01:15,970 Right. 30 00:01:15,990 --> 00:01:19,250 So rotate is what makes it go around, but it goes around forever. 31 00:01:19,260 --> 00:01:25,440 We want to break this loop condition when we touch it, but touching it happens over in the collect 32 00:01:25,440 --> 00:01:28,860 script, so we need those two to talk to each other. 33 00:01:29,280 --> 00:01:37,260 Let's click on coin in the Explorer here, hit a plus and then do a B for Boolean. 34 00:01:37,260 --> 00:01:39,570 So this is a boolean value. 35 00:01:40,200 --> 00:01:48,540 It could be true or false and it's external to both scripts I'm going to write is rotating. 36 00:01:49,080 --> 00:01:49,410 Right. 37 00:01:49,410 --> 00:01:51,570 So this is going to be either true or false. 38 00:01:51,570 --> 00:01:56,730 I'm going to set it to true by hitting this value button checked is true. 39 00:01:56,730 --> 00:01:58,260 Unchecked is false. 40 00:01:58,440 --> 00:02:05,670 Then in my rotate I'm going to say local is rotating. 41 00:02:07,360 --> 00:02:12,340 Equals script to parent or what I could do since script. 42 00:02:12,490 --> 00:02:14,050 Parent is the coin. 43 00:02:14,080 --> 00:02:15,670 I could do coin. 44 00:02:15,880 --> 00:02:16,960 You do either. 45 00:02:17,410 --> 00:02:20,020 I want to find is rotating. 46 00:02:20,020 --> 00:02:20,890 There we go. 47 00:02:20,920 --> 00:02:22,930 That is rotating right here. 48 00:02:23,080 --> 00:02:26,200 Is that boolean value right there, that object. 49 00:02:26,200 --> 00:02:34,030 But in order to access the true or false, we need to have one more thing we're going to say is rotating 50 00:02:34,030 --> 00:02:37,620 dot value, that value right here. 51 00:02:37,630 --> 00:02:40,610 So this is going to be true because we set it to true. 52 00:02:40,630 --> 00:02:48,010 Now the coin will spin just like it did before, but we can change this value external to the rotate 53 00:02:48,010 --> 00:02:48,500 script. 54 00:02:48,520 --> 00:02:49,810 Let's go to collect. 55 00:02:50,050 --> 00:02:53,950 Let's change collect to stop coin. 56 00:02:55,900 --> 00:02:56,690 Here we go. 57 00:02:56,710 --> 00:02:57,940 Let's open it. 58 00:02:58,300 --> 00:03:04,360 Double click on stock coin and then instead of on collect, I'm going to make this a touch event. 59 00:03:04,600 --> 00:03:05,080 Right? 60 00:03:05,080 --> 00:03:08,350 So I'm just going to rename the touch because I think it makes on touch. 61 00:03:08,350 --> 00:03:11,920 I think it makes more sense because we're not collecting it anymore. 62 00:03:11,920 --> 00:03:13,030 We're just touching it. 63 00:03:13,030 --> 00:03:15,040 So I change this to On Touch. 64 00:03:15,040 --> 00:03:20,410 So when we touch the coin, this is the function that'll be called right here. 65 00:03:20,410 --> 00:03:23,920 And then we still want to check to see if it's a humanoid. 66 00:03:23,920 --> 00:03:28,200 We're not going to do powers or destroy it, so I'll delete that. 67 00:03:28,210 --> 00:03:32,650 What we are going to do is modify this is rotating. 68 00:03:33,100 --> 00:03:39,580 In order to make this a little more cleaner code, I'm going to go to the top and right is rotating 69 00:03:39,580 --> 00:03:44,410 get a variable for my is rotating object coin. 70 00:03:45,370 --> 00:03:46,350 If I could spell it right. 71 00:03:46,360 --> 00:03:47,110 There we go. 72 00:03:47,890 --> 00:03:49,300 Is rotating. 73 00:03:50,450 --> 00:03:51,730 This will be the variable. 74 00:03:51,740 --> 00:03:59,000 Come down here, paste it, I'll say dot value equals false. 75 00:03:59,540 --> 00:04:00,080 There we go. 76 00:04:00,080 --> 00:04:02,450 So when we touch it, this will become false. 77 00:04:02,690 --> 00:04:04,400 Go to your rotating script. 78 00:04:04,400 --> 00:04:08,810 This condition is going to be broken because it's going to become false as no longer going to do the 79 00:04:08,810 --> 00:04:09,620 while loop. 80 00:04:09,650 --> 00:04:10,760 Let's try it out. 81 00:04:15,270 --> 00:04:15,720 There we go. 82 00:04:15,730 --> 00:04:16,710 We got the coin. 83 00:04:18,030 --> 00:04:19,530 And it stopped. 84 00:04:19,530 --> 00:04:20,530 Pretty cool. 85 00:04:20,550 --> 00:04:23,740 Let's save this off too, in case we need it for later. 86 00:04:23,760 --> 00:04:25,080 So. 87 00:04:26,130 --> 00:04:27,150 Let's go to our. 88 00:04:27,630 --> 00:04:30,620 See where the coin is right here. 89 00:04:30,630 --> 00:04:32,940 Click it, right click. 90 00:04:32,970 --> 00:04:36,720 And then we're going to say Pablo or save to blocks. 91 00:04:37,230 --> 00:04:41,040 I'm going to overwrite the existing asset you could hit submit. 92 00:04:41,100 --> 00:04:46,470 This distribute on marketplace allows you to distribute it to other people. 93 00:04:46,470 --> 00:04:47,670 They can get it right. 94 00:04:47,670 --> 00:04:50,040 And I had to do that so that you guys could get it. 95 00:04:50,040 --> 00:04:53,100 All I want to do is I'm going to overwrite existing asset. 96 00:04:54,130 --> 00:05:01,300 Coin stops when that's what it was supposed to be when touched and then submit because I already have 97 00:05:01,300 --> 00:05:02,500 one, so I don't need to. 98 00:05:03,100 --> 00:05:03,790 There we go. 99 00:05:03,790 --> 00:05:05,930 So I will see you in the next video. 100 00:05:05,950 --> 00:05:10,840 I think we should do a little bit on tables before we start moving into our game.